package initialize

import (
	"exam/6.11/global"
	"github.com/winksai/utils/mysql"
	"github.com/winksai/utils/nacos"
	"github.com/winksai/utils/redis"
	"github.com/winksai/utils/viper"
)

func Viper() {

	viper.Viper("./config/config.dev.yaml")

}

func Nacos() {
	getNacos := viper.GetNacos()
	nacos.Nacos(getNacos.NameSpace, getNacos.Username, getNacos.Password, getNacos.Addr, getNacos.Port, getNacos.DataID, getNacos.Group)
}

func Mysql() {
	getConfig := nacos.GetConfig()
	config := getConfig.Mysql
	db := mysql.InitMysql(config.User, config.Password, config.Host, config.Database, config.Port)
	//db.AutoMigrate(&model.Product{}, &model.Supplier{}, &model.SupplierProduct{})
	global.GLO_DB = db
}
func Redis() {
	getConfig := nacos.GetConfig()
	config := getConfig.Redis
	rdb := redis.InitRedis(config.Host, config.Password, 0)
	global.RDB = rdb
}
